package com.fulin.thread.condition;

import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.ReentrantLock;

public class TestIntstream {

    private static ReentrantLock lock = new ReentrantLock();
    private static Condition condition = lock.newCondition();



    public static void main(String[] args) {
        Thread t1 = new Thread(()->{
            int i = 0;
           while(true){
               if(i < 1000){
                   i ++;
               }else{
                   try{
                       lock.lock();
                       condition.await();
                   }catch (Exception e){
                       System.out.println("尝试等待出现异常");
                       e.printStackTrace();
                   }finally {
                       lock.unlock();
                   }

                   i = 0;
               }
           }
        });

        t1.start();

        try{
            lock.lock();
            condition.signalAll();
        }finally {
            lock.unlock();
        }
    }


}
